package com.study.samsung.Control;

import com.study.samsung.Entity.Commodity;
import com.study.samsung.Entity.Succession;
import com.study.samsung.Entity.User;
import com.study.samsung.Service.GoodsService;
import com.study.samsung.Service.IndexSearchService;
import com.study.samsung.Utils.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//账号设置
@WebServlet("/AccountSettings")
public class AccountSettingsServlet extends BaseServlet {
    IndexSearchService iss = new IndexSearchService();
    GoodsService gds = new GoodsService();

    @Override
    public String excute(HttpServletRequest request, HttpServletResponse response) throws Exception {
        List<Commodity> newgoods = iss.selectnew();
        List<Succession> selectxl = iss.selectxl();

        request.setAttribute("newgoods",newgoods);
        request.setAttribute("selectxl",selectxl);

        Object user = session.getAttribute("user");
        if (user!=null){
            User nowuser = (User) user;
            Integer uid = nowuser.getUid();

            session.setAttribute("cartcount",gds.cartcount(uid));
        }
        request.setCharacterEncoding("utf-8");
       return "f:AccountSettings";
    }
}
